﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

// -----------------------------------------------------------------------
// <copyright file="$safeitemrootname$.cs" company="$registeredorganization$">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------
namespace NewGame
{
    public class AutoRotationPerspectiveCamera : PerspectiveCamera
    {/*
        private float v0 = (float)Math.PI / 1000;
        private float t = 0;
        private float a = -(float)Math.PI/5000;
        private float lowerBound = -MathHelper.PiOver2;
        private float upperBound = MathHelper.PiOver2;

        private float _lookRotationY;

        public float LookRotationY
        {
            get { return _lookRotationY; }
            set { _lookRotationY = value; }
        }

        public override void UpdateCameraInfo(Fighter fighter)
        {
            base.UpdateCameraInfo(fighter);

            //******************************
            // v = v0 + a * t;
            // x = v0 * t + 1/2 * a * t * t
            //******************************
            t++;
            if (RotationY > lowerBound && RotationY < upperBound)
                RotationY = v0 * t + a * t * t / 2;
            else if (RotationY > upperBound)
            {
                RotationY = upperBound;
                t = 0;
            }
            else if (RotationY < lowerBound)
            {
                RotationY = lowerBound;
                t = 0;
            }

            Vector3 pos = fighter.Position;
            pos.X += (float)(ZoomRate * Math.Cos(RotationY));
            pos.Z += (float)(ZoomRate * Math.Sin(RotationY));
            pos.Y += 0.5f * ZoomRate * (1 + (float)Math.Sin(-fighter.LookRotationZ));
            CameraPosition = pos;

            Vector3 posTarget = fighter.Position;
            posTarget.Y += 0.5f * ZoomRate * (1 + (float)Math.Sin(-fighter.LookRotationZ));
            CameraTarget = posTarget;
            //Vector3 posTarget = fighter.Position;
            //posTarget.X += (float)(ZoomRate * Math.Cos(-RotationY));
            //posTarget.Z += (float)(ZoomRate * Math.Sin(-RotationY));
            //posTarget.Y += 0.5f * ZoomRate * (1 + (float)Math.Sin(-fighter.LookRotationZ));
            //CameraTarget = posTarget;
        }*/
    }
}
